<%@page import="pessoafisica.PessoaFisica" contentType="text/html; charset=UTF-8"%>
<%@page import="java.util.Random"%>
<%@ page import="veiculo.*,fachada.*,modelo.*,cor.*,categoria.*,endereco.*;"%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
<head>
    <!--
    Created by Artisteer v2.5.0.29918
    Base template (without user's data) checked by http://validator.w3.org : "This page is valid XHTML 1.0 Transitional"
    -->
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <title>Loc AutoWeb </title>

    <link rel="stylesheet" href="layout/style.css" type="text/css" media="screen" />
    <!--[if IE 6]><link rel="stylesheet" href="style.ie6.css" type="text/css" media="screen" /><![endif]-->
    <!--[if IE 7]><link rel="stylesheet" href="style.ie7.css" type="text/css" media="screen" /><![endif]-->

    <script type="text/javascript" src="script.js"></script>
</head>
<body>
    <div id="art-page-background-gradient"></div>
    <div id="art-page-background-glare">
        <div id="art-page-background-glare-image"></div>
    </div>
    <div id="art-main">
        <div class="art-sheet">
            <div class="art-sheet-tl"></div>
            <div class="art-sheet-tr"></div>
            <div class="art-sheet-bl"></div>
            <div class="art-sheet-br"></div>
            <div class="art-sheet-tc"></div>
            <div class="art-sheet-bc"></div>
            <div class="art-sheet-cl"></div>
            <div class="art-sheet-cr"></div>
            <div class="art-sheet-cc"></div>
            <div class="art-sheet-body">
                <div class="art-nav">
                	<ul class="art-menu">
                		
                	</ul>
                </div>
                <div class="art-header">
                    <div class="art-header-jpeg"></div>
                    <script type="text/javascript" src="swfobject.js"></script>
                    <div id="art-flash-area">
                    <div id="art-flash-container">
                    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="900" height="225" id="art-flash-object">
                        <param name="movie" value="images/flash.swf" />
                        <param name="quality" value="high" />
                    	<param name="scale" value="exactfit" />
                    	<param name="wmode" value="transparent" />
                    	<param name="flashvars" value="color1=0xFFFFFF&amp;alpha1=.76&amp;framerate1=24&amp;loop=true" />
                        <param name="swfliveconnect" value="true" />
                        <!--[if !IE]>-->
                        <object type="application/x-shockwave-flash" data="layout/images/flash.swf" width="900" height="225">
                            <param name="quality" value="high" />
                    	    <param name="scale" value="exactfit" />
                    	    <param name="wmode" value="transparent" />
                    	    <param name="flashvars" value="color1=0xFFFFFF&amp;alpha1=.76&amp;framerate1=24&amp;loop=true" />
                            <param name="swfliveconnect" value="true" />
                        <!--<![endif]-->
                          	<div class="art-flash-alt"><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></div>
                        <!--[if !IE]>-->
                        </object>
                        <!--<![endif]-->
                    </object>
                    </div>
                    </div>
                    <script type="text/javascript">swfobject.switchOffAutoHideShow();swfobject.registerObject("art-flash-object", "9.0.0", "expressInstall.swf");</script>
                   
                </div>
                <div class="art-content-layout">
                    <div class="art-content-layout-row">
                        <div class="art-layout-cell art-content">
                            <div class="art-post">
                                <div class="art-post-tl"></div>
                                <div class="art-post-tr"></div>
                                <div class="art-post-bl"></div>
                                <div class="art-post-br"></div>
                                <div class="art-post-tc"></div>
                                <div class="art-post-bc"></div>
                                <div class="art-post-cl"></div>
                                <div class="art-post-cr"></div>
                                <div class="art-post-cc"></div>
                                <div class="art-post-body">
                            <div class="art-post-inner art-article">
          

<%
  Fachada fx = new Fachada(); 
  PessoaFisica pf = new PessoaFisica();
  
  if (!request.getParameter("cpf").equals("") && request.getParameter("Submit") == null) {
	  
		  try { 
		
			  String cpf = request.getParameter("cpf");
			  pf = fx.consultarPessoaFisica(cpf);
			   
		  }catch(Exception e){ 
		      response.sendRedirect("mensagem.jsp?texto="+ e.getMessage()+"&pag=TelaAlteracaoUsuario.jsp");
		  }  
		  
	} else if (request.getParameter("Submit") != null) {
		
		   String login = request.getParameter("login").trim();
		   String senha = request.getParameter("senha").trim();
		   String email = request.getParameter("email").trim();
		   String cpf = request.getParameter("cpf").trim();
		   String nome = request.getParameter("nome").trim();
		   
		   String uf = request.getParameter("uf").trim();
		   String cep = request.getParameter("cep").trim();
		   String logradouro = request.getParameter("logradouro").trim();
		   String numero = request.getParameter("numero").trim();
		   String bairro = request.getParameter("bairro").trim();
		   String cidade = request.getParameter("cidade").trim();
		   
		   String fone1 = request.getParameter("fone1").trim();
		   String fone2 = request.getParameter("fone2").trim();
		   			   
		   pf = new PessoaFisica();
		   pf.setLogin(login);
		   pf.setSenha(senha);
		   pf.setEmail(email);
		   pf.setCPF(cpf);
		   pf.setNome(nome);
		   
		   Endereco end = new Endereco();
		   end.setBairro(bairro);
		   end.setCep(Integer.parseInt(cep));
		   end.setCidade(cidade);
		   end.setLogradouro(logradouro);
		   end.setNumero(Integer.parseInt(numero));
		   end.setUf(uf);
		   
		   pf.setEndereco(end);
		   
		   String[] vTelefone = new String[2];
		   vTelefone[0] = ( fone1 != null ) ? fone1 : "0000000000";
		   vTelefone[1] = ( fone2 != null ) ? fone2 : "0000000000";
		   pf.setTelefone(vTelefone);
		   			   
		   fx.alterarPessoaFisica(pf);
		   response.sendRedirect("mensagem.jsp?texto=Dados atualizados com sucesso!&pag=TelaAlteracaoUsuario.jsp");
		
	} else {
		response.sendRedirect("mensagem.jsp?texto=CPF não informado!&pag=TelaAlteracaoUsuario.jsp");
	}
%>

<body>
	<center>
		<h1>Loc AutoWeb - Alterar Pessoa Física</h1>
	</center>
	<br />
	<form name="form1" method="post" action="">
		<table>
			<tbody>
				<tr>
					<td><label>
					Login:</label></td>
					<td><input type="text" name="login" size="15" value="<%=pf.getLogin()%>"></td>
				</tr>
				<tr>&nbsp;</tr>
				<tr>
					<td><label>Senha:</label></td>
					<td><input type="text" name="senha" size="15" value="<%=pf.getSenha()%>"></td>
				</tr>
				<tr>&nbsp;</tr>
				<tr>
					<td><label>E-Mail:</label></td>
					<td><input type="text" name="email" size="20" value="<%=pf.getEmail()%>"></td>
				</tr>
				<tr>&nbsp;</tr>
				<tr>
					<td><label>CPF: (apenas leitura)</label></td>
					<td><input type="text" name="cpf" maxlength="11" readonly="readonly" value="<%=pf.getCPF()%>"></td>
				</tr>
				<tr>&nbsp;</tr>
				<tr>
					<td><label>Nome:</label></td>
					<td><input type="text" name="nome" size="40" value="<%=pf.getNome()%>"></td>
				</tr>
				
				<tr>&nbsp;</tr>
				<tr>
					<td><label>Contato1: 8188334455</label></td>
					<td><input type="text" name="fone1" size="10" maxlength="10" value="<%=pf.getTelefone()[0]%>"></td>
				</tr>
				
				<tr>&nbsp;</tr>
				<tr>
					<td><label>Contato2: 8188334455</label></td>
					<td><input type="text" name="fone2" size="10" maxlength="10" value="<%=pf.getTelefone()[1]%>"></td>
				</tr>
				
				<tr>&nbsp;</tr>
				<tr>
					<td><label>CEP ex: 530606110</label></td>
					<td><input type="text" name="cep" size="10" maxlength="9"  value="<%=pf.getEndereco().getCep()%>"></td>
				</tr>
				<tr>&nbsp;</tr>
				<tr>
					<td><label>UF:</label></td>
					<td><select name="uf">
						<option value="PE" <% if (pf.getEndereco().getUf() == "PE") { out.print("selected='selected'"); } %>>PE</option>
						<option value="AM" <% if (pf.getEndereco().getUf() == "AM") { out.print("selected='selected'"); } %>>AM</option>
						<option value="TO" <% if (pf.getEndereco().getUf() == "TO") { out.print("selected='selected'"); } %>>TO</option>
						<option value="PB" <% if (pf.getEndereco().getUf() == "PB") { out.print("selected='selected'"); } %>>PB</option>
						<option value="RN" <% if (pf.getEndereco().getUf() == "RN") { out.print("selected='selected'"); } %>>RN</option>
						<option value="CE" <% if (pf.getEndereco().getUf() == "CE") { out.print("selected='selected'"); } %>>CE</option>
						<option value="SP" <% if (pf.getEndereco().getUf() == "SP") { out.print("selected='selected'"); } %>>SP</option>
						<option value="RJ" <% if (pf.getEndereco().getUf() == "RJ") { out.print("selected='selected'"); } %>>RJ</option>
						<option value="RS" <% if (pf.getEndereco().getUf() == "RS") { out.print("selected='selected'"); } %>>RS</option>
						<option value="MT" <% if (pf.getEndereco().getUf() == "MT") { out.print("selected='selected'"); } %>>MT</option>
					</select></td>
				</tr>
				<tr>&nbsp;</tr>
				<tr>
					<td><label>Logradouro:</label></td>
					<td><input type="text" name="logradouro" size="40" value="<%=pf.getEndereco().getLogradouro()%>">&nbsp;<input type="text" name="numero" size="10"  value="<%=pf.getEndereco().getNumero()%>"></td>
				</tr>
				<tr>&nbsp;</tr>
				<tr>
					<td><label>Bairro:</label></td>
					<td><input type="text" name="bairro" size="40"  value="<%=pf.getEndereco().getBairro()%>"></td>
				</tr>
				<tr>&nbsp;</tr>
				<tr>
					<td><label>Cidade:</label></td>
					<td><input type="text" name="cidade" size="40"  value="<%=pf.getEndereco().getCidade()%>"></td>
				</tr>
				
				<tr>
					<td colspan="1"><input type="submit" name="Submit" value="Alterar"></td>
					<td><input type="button" onclick="history.back(-1)" value="Voltar"/></td>
				</tr>
			</tbody>
		</table>
	</form>

           
                                            
                                            <div class="cleared"></div>
                            </div>
                            
                            		<div class="cleared"></div>
                    
                                </div>
                            </div>
                           
                        </div>
                    </div>
                </div>
                <div class="cleared"></div><div class="art-footer">
                    <div class="art-footer-t"></div>
                    <div class="art-footer-l"></div>
                    <div class="art-footer-b"></div>
                    <div class="art-footer-r"></div>
                    <div class="art-footer-body">
                         <a href="#" class="art-rss-tag-icon" title="RSS"></a>
                        <div class="art-footer-text">
                            <p>Copyright &copy; 2012 --- É proibida a reprodu&ccedil;&atilde;o total ou parcial do conte&uacute;do deste site para fins comerciais. 
 Tecnologia, Arte e Desenvolvimento: Anderson Elias, Alexsandro Marques, Marcello Pedrosa e Rosiberto Santos.</p>
                        </div>
                		<div class="cleared"></div>
                    </div>
                </div>
        		<div class="cleared"></div>
            </div>
        </div>
        <div class="cleared"></div>
        <p class="art-page-footer"><a href="http://www.facebook.com/locautoweb">Loc AutoWeb</a></p>
    </div>
    
</body>
</html>
